function login(){

    var username = $('#username').val();
    var password = $('#password').val();
    var role = $('select option:selected').val();
    var protocol = window.location.protocol;
    var host = window.location.host;
    $.ajax({
        type : 'POST',
        url : '/login',
        data : {username:username,password:password,role:role},
        success:function (data) {

            if (data == "OK"){
                layer.msg('登录成功', {
                    icon: 1,
                    time: 1000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = protocol+"//"+host+"/index";
                });

            }else {
                layer.open({
                    title: '提示信息',
                    anim: 0,
                    resize:false,//是否可以拉伸  默认true
                    icon: 2,
                    shadeClose: true,
                    skin: 'layui-layer-molv',
                    content: data
                });
            }
        },
        error: function (e) {
            console.log(e)
        }
    });
}